<%@ page import="com.cgt.web.pojo.Banji" %>
<%@ page import="java.util.List" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <link rel="stylesheet" href="static/bootstrap-3.4.1-dist/css/bootstrap.css">
</head>
<body>
    <%
      List<Banji> list = (List<Banji>) request.getAttribute("list");
    %>
    <table class="table table-striped table-bordered table-hover table-condensed">
      <tr>
        <td>ID</td>
        <td>姓名</td>
        <td>地址</td>
      </tr>
      <%
        for (Banji banji : list) {
      %>
      <tr>
        <td><%=banji.getId()%></td>
        <td><%=banji.getName()%></td>
        <td><%=banji.getAddress()%></td>
        <td><a href="/banji?method=toUpdate&id=<%=banji.getId()%>">修改</a></td>
        <td><a href="javascript:void(0)" onclick="deleteById(<%=banji.getId()%>)">删除</a></td>
      </tr>
      <%
        }
      %>
    </table>
    <a class="btn btn-success" href="banji_add.jsp">添加</a>

    <nav aria-label="Page navigation">
        <ul class="pagination">
            <li>
                <a href="#" aria-label="Previous">
                    <span aria-hidden="true">&laquo;</span>
                </a>
            </li>
            <li><a href="#">1</a></li>
            <li><a href="#">2</a></li>
            <li><a href="#">3</a></li>
            <li><a href="#">4</a></li>
            <li><a href="#">5</a></li>
            <li>
                <a href="#" aria-label="Next">
                    <span aria-hidden="true">&raquo;</span>
                </a>
            </li>
        </ul>
    </nav>
    <script>
      function deleteById(id){
        var isDelete = confirm('真的要删除吗？');
        if(isDelete){
          location.href = "/banji?method=deleteById&id=" + id;
        }
      }
    </script>
</body>
</html>
